import Vue from 'vue'
import Router from 'vue-router'

const _import = require('./_import_' + process.env.NODE_ENV)
// in development-env not use lazy-loading, because lazy-loading too many pages will cause webpack hot update too slow. so only in production use lazy-loading;
// detail: https://panjiachen.github.io/vue-element-admin-site/#/lazy-loading

Vue.use(Router)

/* Layout */
import Layout from '../views/layout/Layout'

/** note: submenu only apppear when children.length>=1
 *   detail see  https://panjiachen.github.io/vue-element-admin-site/#/router-and-nav?id=sidebar
 **/

/**
 * hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
 *                                if not set alwaysShow, only more than one route under the children
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noredirect           if `redirect:noredirect` will no redirct in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    roles: ['admin','editor']     will control the page roles (you can set multiple roles)
    title: 'title'               the name show in submenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar,
    noCache: true                if true ,the page will no be cached(default is false)
  }
 **/
export const constantRouterMap = [
	{path: '/login', component: _import('login/index'), hidden: true},
	{path: '/404', component: _import('errorPage/404'), hidden: true},
	{path: '/401', component: _import('errorPage/401'), hidden: true},
	{
		path: '',
		component: Layout,
		redirect: 'dashboard',
		children: [{
			path: 'dashboard',
			component: _import('dashboard/index'),
			name: 'dashboard',
			meta: {title: 'dashboard', icon: 'dashboard', noCache: true}
		}]
	},

]

export default new Router({
	mode: 'hash', // require service support
	scrollBehavior: () => ({y: 0}),
	routes: constantRouterMap
})

export const asyncRouterMap = [
	{
		path: '/setting',
		component: Layout,
		hidden: true,
		meta: {icon: 'component', title: 'setting'},
		children: [
			{
				path: 'company',
				component: _import('setting/company/index'),
				name: 'companySet',
				meta: {title: 'companySet', icon: 'icon', noCache: true},
			},
			{
				path: 'profile',
				component: _import('setting/profile/index'),
				name: 'profileSet',
				meta: {title: 'profileSet', icon: 'icon', noCache: true},
			},
			{
				path: 'account',
				component: _import('setting/account/index'),
				name: 'accountCenter',
				meta: {title: 'accountCenter', icon: 'icon', noCache: true}
			}
		]
	},
	{
		path: '/erweima',
		component: Layout,
		hidden: true,
		children: [
			{
				path: 'zhaopin',
				component: _import('erweima/zhaopin'),
				name: 'zhaopinEr',
				meta: {title: 'zhaopinEr'}
			},
			{
				path: 'yingpin',
				component: _import('erweima/yingpin'),
				name: 'yingpinEr',
				meta: {title: 'yingpinEr'}
			},
			{
				path: 'peixun',
				component: _import('erweima/peixun'),
				name: 'peixunEr',
				meta: {title: 'peixunEr'}
			},
		]
	},
	{
		path: '/message',
		hidden: true,
		component: Layout,
		meta: {icon: 'component', title: 'message'},
		children: [{
			path: 'index',
			component: _import('message/index'),
			name: 'message',
			meta: {title: 'message', icon: 'icon', noCache: true}
		}]
	},
	{
		path: '/unit',
		component: Layout,
		meta: {icon: 'component', title: 'unit'},
		children: [
			{
				path: 'unit',
				component: _import('unit/unit/index'),
				name: 'unit',
				meta: {title: 'unit', icon: 'unit', noCache: true}
			},
			{
				path: 'editor',
				component: _import('unit/editor/index'),
				name: 'unitEdit',
				hidden: true,
				meta: {title: 'unitEdit', icon: 'unit', noCache: true}
			},
		]
	},
	
	{
		path: '/job',
		component: Layout,
		meta: {icon: 'component', title: 'job'},
		children: [
			{
				path: 'index',
				component: _import('job/index'),
				name: 'job',
				meta: {title: 'job', icon: 'job', noCache: true}
			},
			{
				path: 'editor',
				component: _import('job/editor/index'),
				name: 'jobEditor',
				hidden:true,
				meta: {title: 'jobEditor', icon: 'job', noCache: true}
			}
		]
	},
	{
		path: '/entry',
		component: Layout,
		meta: {icon: 'component', title: 'entry'},
		children: [
			{
				path: 'sign',
				component: _import('entry/sign/index'),
				name: 'sign',
				meta: {title: 'sign', icon: 'sign', noCache: true}
			},
			{
				path: 'hire',
				component: _import('entry/hire/index'),
				name: 'hire',
				meta: {title: 'hire', icon: 'people_ok', noCache: true}
			},
			{
				path: 'unhire',
				component: _import('entry/unhire/index'),
				name: 'unhire',
				meta: {title: 'unhire', icon: 'people_no', noCache: true}
			},
			{
				path: 'employ',
				component: _import('entry/employ/index'),
				name: 'employ',
				meta: {title: 'employ', icon: 'people_ok', noCache: true}
			},
			{
				path: 'unemploy',
				component: _import('entry/unemploy/index'),
				name: 'unemploy',
				meta: {title: 'unemploy', icon: 'people_no', noCache: true}
			},
			{
				path: 'quit',
				component: _import('entry/quit/index'),
				name: 'quit',
				meta: {title: 'quit', icon: 'people_no', noCache: true}
			},
		
		]
	},
	{
		path: '/workerBank',
		component: Layout,
		meta: {icon: 'workerBank', title: 'workerBank'},
		children: [
			{
				path: 'online',
				component: _import('workerBank/online/index'),
				name: 'online',
				meta: {title: 'online', icon: 'online', noCache: true},
			},
			{
				path: 'hostworker',
				component: _import('workerBank/hostworker/index'),
				name: 'hostworker',
				flex: true,
				meta: {title: 'hostworker', icon: 'hostWorker', noCache: true},
			},
			{
				path: 'blackList',
				component: _import('workerBank/blackList/index'),
				name: 'blackList',
				meta: {title: 'blackList', icon: 'people_no', noCache: true},
			}
		]
	},
	{
		path: '/supplier',
		component: Layout,
		meta: {icon: 'supplier', title: 'supplier'},
		children: [
			{
				path: 'supplier',
				component: _import('supplier/supplier/index'),
				name: 'supplier',
				meta: {title: 'supplier', icon: 'supplier', noCache: true}
			},
		]
	},
	{
		path: '/interview',
		component: Layout,
		meta: {icon: 'interviewer', title: 'interview'},
		children: [
			{
				path: 'interviewer',
				component: _import('interview/interviewer/index'),
				name: 'interview',
				flex: true,
				meta: {title: 'interviewer', icon: 'interviewer', noCache: true}
			},
			{
				path: 'set',
				component: _import('interview/set/index'),
				name: 'interviewSet',
				flex: true,
				meta: {title: 'interviewSet', icon: 'set', noCache: true}
			},
			{
				path: 'jobInterview',
				component: _import('interview/jobInterview/index'),
				name: 'jobInterview',
				flex: true,
				meta: {title: 'jobInterview', icon: 'job', noCache: true}
			}
		]
	},
	{
		path: '/train',
		component: Layout,
		meta: {icon: 'train', title: 'train'},
		children: [
			{
				path: 'index',
				component: _import('train/index'),
				flex: true,
				name: 'train',
				meta: {title: 'train', icon: 'train', noCache: true}
			},
			{
				path: 'jobTrain',
				component: _import('train/jobTrain/index'),
				name: 'jobTrain',
				flex: true,
				meta: {title: 'jobTrain', icon: 'job', noCache: true}
			}
		]
	},
	{
		path: '/spread',
		component: Layout,
		meta: {icon: 'component', title: 'spread'},
		children: [{
			path: 'index',
			component: _import('spread/index'),
			name: 'spread',
			meta: {title: 'spread', icon: 'spread', noCache: true}
		}]
	},
	{
		path: '/stat',
		component: Layout,
		meta: {icon: 'component', title: 'stat'},
		children: [{
			path: 'index',
			component: _import('stat/index'),
			name: 'stat',
			meta: {title: 'stat', icon: 'chart', noCache: true}
		}]
	},
	{
		path: '/operate',
		component: Layout,
		meta: {icon: 'component', title: 'operate'},
		children: [{
			path: 'index',
			component: _import('operate/index'),
			name: 'operate',
			meta: {title: 'operate', icon: 'operate', noCache: true}
		}]
	},
	
	{
		path: '/svg',
		hidden: true,
		component: Layout,
		meta: {icon: 'component', title: 'svg'},
		children: [{
			path: 'icons',
			component: _import('svg-icons/index'),
			name: 'svg',
			meta: {title: 'svg', icon: 'icon', noCache: true}
		}]
	},
	
	
	{path: '*', redirect: '/404', hidden: true}
]
